package org.agile2soft.nexoma.expedient.ioc;

import org.agile2soft.nexoma.core.controllers.ProfilesController;
import org.agile2soft.nexoma.core.dao.ProfileDAO;
import org.agile2soft.nexoma.expedient.controllers.DocumentController;
import org.agile2soft.nexoma.expedient.controllers.ExpedientController;
import org.agile2soft.nexoma.expedient.controllers.ExpedientPhaseController;
import org.agile2soft.nexoma.expedient.controllers.ExpedientTypeController;
import org.agile2soft.nexoma.expedient.controllers.ExpedientTypePhaseController;
import org.agile2soft.nexoma.expedient.controllers.ExpedientTypePhaseExpedientsController;
import org.agile2soft.nexoma.expedient.controllers.impl.DocumentControllerImpl;
import org.agile2soft.nexoma.expedient.controllers.impl.ExpedientControllerImpl;
import org.agile2soft.nexoma.expedient.controllers.impl.ExpedientPhaseControllerImpl;
import org.agile2soft.nexoma.expedient.controllers.impl.ExpedientTypeControllerImpl;
import org.agile2soft.nexoma.expedient.controllers.impl.ExpedientTypePhaseControllerImpl;
import org.agile2soft.nexoma.expedient.controllers.impl.ExpedientTypePhaseExpedientsControllerImpl;
import org.agile2soft.nexoma.expedient.dao.DocumentDAO;
import org.agile2soft.nexoma.expedient.dao.ExpedientDAO;
import org.agile2soft.nexoma.expedient.dao.ExpedientPhaseDAO;
import org.agile2soft.nexoma.expedient.dao.ExpedientTypeDAO;
import org.agile2soft.nexoma.expedient.dao.ExpedientTypePhaseDAO;
import org.agile2soft.nexoma.expedient.dao.ExpedientTypePhaseExpedientsDAO;
import org.agile2soft.nexoma.expedient.dao.hibernate.DocumentDAOImpl;
import org.agile2soft.nexoma.expedient.dao.hibernate.ExpedientDAOImpl;
import org.agile2soft.nexoma.expedient.dao.hibernate.ExpedientPhaseDAOImpl;
import org.agile2soft.nexoma.expedient.dao.hibernate.ExpedientTypeDAOImpl;
import org.agile2soft.nexoma.expedient.dao.hibernate.ExpedientTypePhaseDAOImpl;
import org.agile2soft.nexoma.expedient.dao.hibernate.ExpedientTypePhaseExpedientsDAOImpl;
import org.hibernate.SessionFactory;
import org.springframework.config.java.annotation.Bean;
import org.springframework.config.java.annotation.Configuration;
import org.springframework.config.java.annotation.ExternalBean;
import org.springframework.config.java.annotation.Import;
import org.springframework.config.java.annotation.Lazy;

import br.com.arsmachina.dao.hibernate.ioc.PersistenceConfiguration;

/**
 * Main configuration class for Spring JavaConfig. It just imports the other configuration classes.
 *
 * @author Antonio M. Fernandez Rodriguez
 */
@Configuration(defaultLazy = Lazy.TRUE)
@Import({PersistenceConfiguration.class,ExpedientConfiguration.class})
public class ExpedientConfiguration {

	/**
	 * Declares a <code>sessionFactory</code> bean, defined elsewhere.
	 * 
	 * @return a {@link SessionFactory}.
	 */
	@ExternalBean
	public SessionFactory sessionFactory() {
		return null;
	}
	
	/**
	 * Declares the <code>expedient </code>dao  bean.
	 * 
	 * @return a {@link Expedient DAO}.
	 */
	@Bean
	public ExpedientDAO expedientDAO() {
		return new ExpedientDAOImpl(sessionFactory());
	}

	/**
	 * Declares the <code>expedientController</code> bean.
	 * 
	 * @return a {@link ExpedientController}.
	 */
	@Bean
	public ExpedientController profileController() {
		return new ExpedientControllerImpl(expedientDAO());
	}	
	
	/**
	 * Declares the <code>expedientType</code> dao bean
	 * 
	 * @return a {@link ExpedientTypeDAO}
	 */
	@Bean
	public ExpedientTypeDAO expedientTypeDAO() {
		return new ExpedientTypeDAOImpl(sessionFactory());
	}
	
	/**
	 * Declares the <code> expedientController </code bean.
	 * 
	 * @return a {@link ExpedientTypeController}.
	 */
	public ExpedientTypeController expedientTypeController() {
		return new ExpedientTypeControllerImpl(expedientTypeDAO());
	}

	/**
	 * Declares the <code>expedientTypePhase</code> dao bean  
	 *
	 * @return a {@link ExpedientTypePhaseDAO}.
	 */
	public ExpedientTypePhaseDAO expedientTypePhaseDAO() {
		return new ExpedientTypePhaseDAOImpl(sessionFactory());
	}
	
	/**
	 * Declares the <code> expedientController </code> manager bean.
	 * 
	 * @return a {@link ExpedientTypeController}.
	 */
	public ExpedientTypePhaseController expedientTypePhaseController() {
		return new ExpedientTypePhaseControllerImpl(expedientTypePhaseDAO());
	}

	/**
	 * Declares the <code>expedientTypePhase</code> dao bean  
	 *
	 * @return a {@link ExpedientPhaseDAO}.
	 */
	public ExpedientPhaseDAO expedientPhaseDAO() {
		return new ExpedientPhaseDAOImpl(sessionFactory());
	}

	/**
	 * Declares the <code> expedientController </code> manager bean.
	 * 
	 * @return a {@link ExpedientTypeController}.
	 */
	public ExpedientPhaseController expedientPhaseController() {
		return new ExpedientPhaseControllerImpl(expedientPhaseDAO());
	}
	/****************/
	/**
	 * Declares the <code>expedientTypePhase</code> dao bean  
	 *
	 * @return a {@link ExpedientPhaseDAO}.
	 */
	public ExpedientTypePhaseExpedientsDAO expedientTypePhaseExpedientsDAO() {
		return new ExpedientTypePhaseExpedientsDAOImpl(sessionFactory());
	}

	/**
	 * Declares the <code> expedientController </code> manager bean.
	 * 
	 * @return a {@link ExpedientTypeController}.
	 */
	public ExpedientTypePhaseExpedientsController expedientTypePhaseExpedientsController() {
		return new ExpedientTypePhaseExpedientsControllerImpl(expedientTypePhaseExpedientsDAO());
	}
	
	/**
	 * Declares the <code> document</code> dao bean.
	 * 
	 * @return a {@link DocumentDAO}.
	 */
	public DocumentDAO documentDAO() {
		return new DocumentDAOImpl(sessionFactory());
	}
	
	/**
	 * Declares the <code>documentController</code> bean  
	 *
	 * @return a {@link DocumentController}.
	 */
	public DocumentController documentController() {
		return new DocumentControllerImpl(documentDAO());
	}
	
}
